package com.fare.taluo.application.impl.report;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fare.taluo.application.report.air.AirChinaTaobaoApplication;
import com.fare.taluo.fetl.domain.entity.AirChinaTaobaoEntity;
import com.fare.taluo.vo.taobaoPriceRubik.TaobaoPriceRubikVO;
@Transactional
@Scope("singleton")
@Service("airChinaTaobaoApplication")
public class AirChinaTaobaoApplicationImpl implements AirChinaTaobaoApplication{

	/**
	 * 处理tabao报表（国内）
	*/
	@Override
	public List<TaobaoPriceRubikVO> findByCondition(Date reportDate,
			Date flightDate, String fromCityCode, String toCityCode,
			String flightNo, String carrierKey, String hbaseKey) {
		AirChinaTaobaoEntity lp=new AirChinaTaobaoEntity();
		List<TaobaoPriceRubikVO> listVo=new ArrayList<TaobaoPriceRubikVO>();
		List<AirChinaTaobaoEntity> listEntity=new ArrayList<AirChinaTaobaoEntity>();
		listEntity=lp.findByCondition(reportDate, flightDate, fromCityCode, toCityCode, flightNo, carrierKey, hbaseKey);
		
		if(listEntity.size()>0){
			for(AirChinaTaobaoEntity entity:listEntity){
				TaobaoPriceRubikVO vo=new TaobaoPriceRubikVO();
				vo.setAgentLowerPrice(entity.getUltimatePrice()+"");
				vo.setLowerPrice(entity.getAgentPrice()+"");
				vo.setCarrierKey(entity.getCarrierKey());
				vo.setFlightId(entity.getFlightNo());
				vo.setFromCity(entity.getFromCityCode());
				vo.setToCity(entity.getToCityCode());
				vo.setCarrierName(entity.getCarrierKey());//（本来应该存放航空公司名字）暂时存放航空公司代码
//				vo.setGrabDate()//抓取时间戳
				
				listVo.add(vo);
			}
			
		}
		
		return listVo;
	}

}
